<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
             
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
  <head>
    <base href="<%=basePath%>"> 
    
    <title></title>
    	<link rel="stylesheet" type="text/css" href="css/edittable.css"  ></link>  
		<link rel="stylesheet" type="text/css" href="css/validate.css"  ></link>  
		<script type="text/javascript"  src="js/jquery-1.8.0.js"></script>

	 <script>		
	 		function  checkadminName(){
	 				var result=true;
	 				var reg=/^\w{4,15}$/;
	 				var adminName=$("#adminName").val();
					if(!reg.test(adminName)){
					$("#adminName_msg").html("用户名格式非法! ").css("color","red");
						result=false;
	 				}
					else{
						 $.ajax({
							 url:"AdminServlet.do?flag=check",
							 type:"POST",
							 data:{adminName:adminName},
							 async:false,
							 success:function(data){
								 if("0"==data){
									 result=false;
									 $("#adminName_msg").html("用户名重复!").css("color","red");
								 }
							 },
						});
					}
					if(result==true){
						 $("#adminName_msg").html("验证通过").css("color","green"); 
					 }
					return result;
	 			}
	 		function  checkpassword(){
	 				var result=true;
					var reg=/^\w{6,20}$/;
					if(!reg.test($("#password").val())){
						$("#password_msg").html("密码格式非法! ").css("color","red");
						result=false;
	 	   		} 
					else{
						$("#password_msg").html("验证通过 ").css("color","green");
						}
					return result;
 			}
			function  pwdconfirm(){
				var result=true;
					if($("#pwdconfirm").val()!=$("#password").val()){
						$("#pwdconfirm_msg").html("两次输入的密码不一致! ").css("color","red");
						result=false;
	 	   			} 
					else{
						$("#pwdconfirm_msg").html("验证通过 ").css("color","green");
						}
					return result;
 			}
			function checkAll(){
				var result=true;
				if(checkadminName()==false)
					result=false;
				if(checkpassword()==false)
					result=false;
				if(pwdconfirm()==false)
					result=false
					if(result==true){
 		 				return confirm("确定要提交吗");
 		 		}
				if(result==false){
					alert("部分信息错误请重新修改");
				}
				return result;
			}
			$(function(){
				 $("input[type=text],textarea").focus(function(){
					  $(this).addClass("input_focus");
					}).blur(function(){
							$(this).removeClass("input_focus");
					});

				$(".form_btn").hover(function(){
						$(this).css("color","red").css("background","#6FB2DB");
					},
					
					function(){
						$(this).css("color","#295568").css("background","#BAD9E3");
					});	
				$("#adminName").focus(function(){
					$("#adminName_msg").html("4-15位；只限数字(0-9)和英文(a-z),不区分大小写").css("color","#8FA0AC");
				}).blur(checkadminName);
				$("#password").focus(function(){
					$("#password_msg").html("数字或英文,6-20位").css("color","#8FA0AC");
				}).blur(checkpassword);
				$("#pwdconfirm").focus(function(){
					$("#pwdconfirm_msg").html("请重复输入密码").css("color","#8FA0AC");
				}).blur(pwdconfirm);
				
			});		
	</script>
    
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	
	
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
     <div class ="div_title">
		 <div class="div_titlename"> <img src="images/san_jiao.gif" ><span>管理员添加</span></div>
	 </div>
				 
	 <form action="AdminServlet.do?flag=add"  method="post">
		 <table class="edit_table" >
		 		<tr>
		 			 	<td class="td_info">用户账号:</td>	
		 			 	<td class="td_input_short"> 
		 			 		<input type="text" class="txtbox" id="adminName" name="adminName" value="${param.adminName}"/> 
		 			 	</td>   
		 			 	<td>
		 			 		<label class="validate_info" id="adminName_msg"  >4-15位；只限数字(0-9)和英文(a-z),不区分大小写</label>
		 			 	</td> 
		 		</tr>
		 			<tr>
		 				<td class="td_info">用户密码:</td>	
		 				<td>
		 					<input type="password"  class="txtbox"  name="password"  id="password" value="${param.password}"/>
		 				</td> 
		 				<td><label  class="validate_info" id="password_msg" >数字或英文,6-20位</label></td>	
		 		</tr>
		 			<tr>
		 				<td class="td_info">重复密码:</td>	
		 				<td><input type="password" class="txtbox" id="pwdconfirm" name="pwdconfirm" value="${param.password}" /> 
		 				</td>
		 				<td><label  class="validate_info"  id="pwdconfirm_msg">请重复输入密码</label></td>	
		 		</tr>
		 		<tr>
		 			<td class="td_info">备注信息:</td>	
		 			<td><textarea rows="4" cols="27" name="note" id="note" class="txtarea"  >${param.note}</textarea> </td>	
		 			<td><label></label></td>	
		 		</tr>
		 		<tr>
		 			<td class="td_info"> </td>	
		 			<td> 
		 			<input class="form_btn" type="submit" value="提交" onclick="return checkAll()"/> 
		 			<input type="reset"  class="form_btn" value="重置" /> </td>	
		 			<td>
		 				<label id="result_msg" class="result_msg">${msg}</label>
		 			</td>	
		 		</tr>
		</table>
     </form>
  </body>
</html>